<template>
  <div class="chart-box" ref="mapChart"></div>
</template>

<script setup lang="ts">
import * as echarts from "echarts"
import { onMounted, ref } from "vue"
import china from "@/assets/china.json"

let chart: any
const mapChart = ref<HTMLElement>()

const option = {
  geo:{
    map:'china'
  }
}

onMounted(() => {
  initChart()
})

const initChart = () => {
  if (mapChart.value) {
    echarts.registerMap("china", china as any)
    chart = echarts.init(mapChart.value)
    chart.setOption(option)
  }
}
</script>

<style lang="scss" scoped>
.chart-box {
  width: 400px;
  height: 400px;
  border: 1px solid red;
}
</style>
